import { post } from "utils/fetch";

const PREFIX = "/flow-platform";

/**
 * 统计-任务明细
 * @param {
 *"pageNum":1,
  "pageSize":10,
  "modelKey":"copyapplication1", //流程编码
  "modelName":"请假",  //流程名称
  "taskName":"任务名称",  //任务名称
  "activityId":"任务编码",  //任务编码
  "status":"NORMAL",  //状态
  "startTime":"2019-08-26 09:49:55",  //开始时间
  "endTime":"2019-08-26 09:49:56"   //结束时间
  "appId":"1"      // 应用ID
  "busiId":"153"   // 业务ID
  "tenantId":"2"   // 租户ID

 * }
 */
const getTaskDetail = ({
  pageNum,
  pageSize,
  modelKey,
  modelName,
  taskName,
  activityId,
  status,
  startTime,
  endTime,
  appId,
  busiId,
  tenantId,
}) =>
  post(`${PREFIX}/statistics/task/list`, {
    pageNum,
    pageSize,
    modelKey,
    modelName,
    taskName,
    activityId,
    status,
    startTime,
    endTime,
    appId,
    busiId,
    tenantId,
  });

/**
 * 统计-实例明细
 * @param {
 *"pageNum": 1,
	"pageSize": 10,
	"modelKey": "copyapplication1", //流程编码
	"modelName": "请假",  //流程名称
	"status": "NORMAL",  //状态
	"processInstanceId": "cdc706aec7a311e9870f0250f2000002", //实例id
	"startTime": "2019-08-26 09:49:55",  //开始时间
  "endTime": "2019-08-26 09:49:56"  //结束时间
  "appId":"1"      // 应用ID
  "busiId":"153"   // 业务ID
  "tenantId":"2"   // 租户ID

 * }
 */
const getProcessInstanceDetail = ({
  pageNum,
  pageSize,
  modelKey,
  modelName,
  status,
  processInstanceId,
  startTime,
  endTime,
  appId,
  busiId,
  tenantId,
}) =>
  post(`${PREFIX}/statistics/processInstance/list`, {
    pageNum,
    pageSize,
    modelKey,
    modelName,
    status,
    processInstanceId,
    startTime,
    endTime,
    appId,
    busiId,
    tenantId,
  });

/**
 * 统计-任务统计
 * @param
 *"pageNum":1,
 "pageSize":10,
 "summaryType":"byDay", //按日：byDay, 按月：byMonth
 "startDate":"2019-08-26", //开始日期
 "endDate":"2019-08-27",  //结束日期
 "year":"2019",
 "months":["8", "9"]
 "months":["8", "9"]
 "appId":"1"      // 应用ID
 "busiId":"153"   // 业务ID
 "tenantId":"2"   // 租户ID

 */
const getTaskTotal = ({
  pageNum,
  pageSize,
  summaryType,
  startDate,
  endDate,
  year,
  months,
  appId,
  busiId,
  tenantId,
}) =>
  post(`${PREFIX}/statistics/task/summary`, {
    pageNum,
    pageSize,
    summaryType,
    startDate,
    endDate,
    year,
    months,
    appId,
    busiId,
    tenantId,
  });

/**
 * 统计-实例统计
 * @param
 *"pageNum":1,
 "pageSize":10,
 "summaryType":"byDay", //按日：byDay, 按月：byMonth
 "startDate":"2019-08-26", //开始日期
 "endDate":"2019-08-27",  //结束日期
 "year":"2019",
 "months":["8", "9"]
 "appId":"1"      // 应用ID
 "busiId":"153"   // 业务ID
 "tenantId":"2"   // 租户ID

 */
const getProcessInstanceTotal = ({
  pageNum,
  pageSize,
  summaryType,
  startDate,
  endDate,
  year,
  months,
  appId,
  busiId,
  tenantId,
}) =>
  post(`${PREFIX}/statistics/processInstance/summary`, {
    pageNum,
    pageSize,
    summaryType,
    startDate,
    endDate,
    year,
    months,
    appId,
    busiId,
    tenantId,
  });

export default {
  getTaskDetail,
  getProcessInstanceDetail,
  getTaskTotal,
  getProcessInstanceTotal,
};
